package cn.com.netedge.iot.frontend.datasave.model.freeze;

import java.util.ArrayList;
import java.util.List;

public class FreezeEventDataModel {

    private String pID;
    private int protocol;
    private int deviceId;
    private int deviceType;

    private String description;

    /*数据库表名*/
    private String tableName;
    /*动态列值以及类型*/
    private List<ColumnDataModel> columnDataModels;

    private String dynamicsColumns;
    private String dynamicsValues;

    public String getDynamicsValues() {
        if (!columnDataModels.isEmpty()) {
            String valueStr = "";
            for (ColumnDataModel col : columnDataModels) {
                if ("numeric".equals(col.getDataType())) {
                    valueStr += "," + (col.getDataValue().contains(",")?col.getDataValue().replace(',','.') :col.getDataValue());
                }
                else {
                    valueStr += ",'" + col.getDataValue() + "'";
                }
            }

            dynamicsValues = valueStr;
            return dynamicsValues;
        }
        return "";
    }


    public String getDynamicsColumns() {
        if (columnDataModels.isEmpty())
            return "";

        String colStr = "";
        for (ColumnDataModel col : columnDataModels) {
            colStr += "," + col.getColumnName();
        }

        this.dynamicsColumns = colStr;
        return dynamicsColumns;
    }

    public String getpID() {
        return pID;
    }

    public void setpID(String pID) {
        this.pID = pID;
    }

    public int getProtocol() {
        return protocol;
    }

    public void setProtocol(int protocol) {
        this.protocol = protocol;
    }

    public int getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(int deviceId) {
        this.deviceId = deviceId;
    }

    public int getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(int deviceType) {
        this.deviceType = deviceType;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }


    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public List<ColumnDataModel> getColumnDataModels() {
        return columnDataModels;
    }

    public void setColumnDataModels(List<ColumnDataModel> columnDataModels) {
        this.columnDataModels = columnDataModels;
    }

    public FreezeEventDataModel() {
        this.columnDataModels = new ArrayList<>();
    }

}
